<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <span>初始数字:</span>
  <span id="num">0</span>
  <button id="reduce">-</button>
  <button id="add">+</button>
  <script>
  window.onload=function(){
    let reduce = document.getElementById("reduce")
    let add = document.getElementById("add")
    let myNum = document.getElementById("num")
    reduce.onclick=function(){
      if(Number(myNum.innerHTML)>0){
        myNum.innerHTML = Number(myNum.innerHTML) - 1
      }
    }
    add.onclick=function(){
      myNum.innerHTML = Number(myNum.innerHTML) + 1
    }
  }
  </script>
</body>
</html>